package com.qyhl.webtv.module_live.teletext.newlivelist.item;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.qyhl.webtv.basiclib.utils.StringUtils;
import com.qyhl.webtv.commonlib.entity.live.LiveRoomBean;
import com.qyhl.webtv.module_live.R;
import com.zhy.adapter.recyclerview.base.ItemViewDelegate;
import com.zhy.adapter.recyclerview.base.ViewHolder;

public class InteractionItemView implements ItemViewDelegate<LiveRoomBean> {
    private Context context;

    public InteractionItemView(Context context) {
        this.context = context;
    }

    @Override
    public int getItemViewLayoutId() {
        return R.layout.live_item_teletext_list;
    }

    @Override
    public boolean isForViewType(LiveRoomBean liveRoomBean, int i) {
        return liveRoomBean.getLivetype().equals("interactive");
    }

    @Override
    public void convert(ViewHolder viewHolder, LiveRoomBean liveRoomBean, int i) {
        viewHolder.setText(R.id.item_live_title, liveRoomBean.getTitle());
        String hitCount = liveRoomBean.getHitcount();
        if (!StringUtils.isEmpty(hitCount)) {
            viewHolder.setText(R.id.item_live_friends, hitCount + "人参与");
        } else {
            viewHolder.setText(R.id.item_live_friends, "0人参与");
        }

        ImageView bg = viewHolder.getView(R.id.item_live_logo);

        viewHolder.setVisible(R.id.item_live_tagtype, false);
        viewHolder.setVisible(R.id.live_status, false);
        Glide.with(context)
                .load(liveRoomBean.getLogo())
                .apply(new RequestOptions().error(R.drawable.cover_large_default))
                .into(bg);
    }
    
}
